<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var arr = [
      {
        name: '张三',
        gender: 1,
        level: 1
      },
      {
        name: '李四',
        gender: 0,
        level: 2
      },
      {
        name: '王五',
        gender: 1,
        level: 3
      },
      {
        name: '钱六',
        gender: 6,
        level: 3
      }
    ]
    // arr.map(item => {
    //   if (item.gender === 1){
    //     item.genders = '男'
    //   } else if (item.gender === 0) {
    //     item.genders = '女'
    //   } else {
    //     item.genders = '未知'
    //   }
    //   delete item.gender
    // })
    arr.map(item => {
      switch(item.gender) {
        case 1:
        item.genders = '男'
        break
        case 0:
        item.genders = '女'
        break
        default:
        item.genders= '未知'
      }
    })
    console.log(arr)
  </script>
</body>
</html>